/*
 * @Author: WangLi
 * @Date: 2021-07-22 14:31:17
 * @LastEditors: WangLi
 * @LastEditTime: 2021-07-22 14:52:42
 * @Description:
 */

export function getThemeCluster(theme) {
  const tintColor = (color, tint) => {
    let red = parseInt(color.slice(0, 2), 16);
    let green = parseInt(color.slice(2, 4), 16);
    let blue = parseInt(color.slice(4, 6), 16);

    if (tint !== 0) {
      red += Math.round(tint * (255 - red));
      green += Math.round(tint * (255 - green));
      blue += Math.round(tint * (255 - blue));

      red = red.toString(16);
      green = green.toString(16);
      blue = blue.toString(16);

      return `#${red}${green}${blue}`;
    }
  };
  const lights = [];
  for (let i = 1; i <= 9; i++) {
    lights.push(tintColor(theme, Number((i / 10).toFixed(2))));
  }
  return lights;
}
